home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / util / comm / araintel.sit / Intel 14.4EX next >
Encoding:
Text File  |  1992-09-30  |  10.4 KB  |  347 lines

  1. ! "Intel 14.4EX Modem 9/30/92" Jim Gaynor
  2. ! Adapted from the Telebit WorldBlazer script, with parts from the
  3. ! SupraFAXModem v.32bis script and Microcom MacModem script
  4. ! "Telebit WorldBlazer Modem (V.32bis) 6/4/92" JFK
  5. ! Adapted from the Telebit T3000 script
  6. ! "Telebit T3000 Modem 11/11/91" JFK
  7. !
  8. @ORIGINATE
  9. @ANSWER
  10. !
  11. ! Talk to the modem at 19,200 bps.  The Intel should auto-baud this
  12. ! unless the user has locked the port to a particular speed.  If it
  13. ! is locked to a different speed, the user will need to change that.
  14. !
  15. serreset 19200, 0, 8, 1
  16. !
  17. ! The idea here is to get the modem into a known state, and then change only 
  18. ! the registers that are necessary to support the connection.  Most of the 
  19. ! time AT&F will be sufficient, but some modems allow the user to change the 
  20. ! F0 parameters.  There isn't much that can be done to prevent this, but if 
  21. ! the modem has any pre-configured configurations, and one of them sets 
  22. ! hardware handshaking, use it.
  23. !
  24. ! Recall the factory configuration
  25. !
  26. settries 0
  27. matchclr
  28. @LABEL 1
  29. matchstr 1 4 "OK\13\10"
  30. write "AT&F\13"
  31. matchread 30
  32. inctries
  33. iftries 2 59
  34. ! Modem is not responding, reset and send a break
  35. DTRClear
  36. pause 5
  37. DTRSet
  38. SBreak
  39. jump 1
  40. !
  41. !  The script was able to get the modem into a default factory state.  Now 
  42. !  set the basic hardware type configuration such as command echo, hardware 
  43. !  handshaking, and DTR control.  If the &F command had not set up handshaking 
  44. !  this is where it would be done.  It's not desirable to create one long 
  45. !  command string with everything on it because some modems cannot handle a 
  46. !  long command string, and long strings are harder to debug.  It's easy
  47. !  to enter an incorrect S-register value.  For the most part, the following 
  48. !  commands are probably common across a lot of modems, but always look up the 
  49. !  commands in the modem manual.
  50. !
  51. ! Next, Set up the configuration: drop connection after losing DTR
  52. !    Turn off auto answer and command echo.   
  53. !
  54. ! S0=0 - Don't answer calls
  55. ! E0   - Turn command echo off
  56. @LABEL 4
  57. matchclr
  58. pause 5
  59. matchstr 1 5 "OK\13\10"
  60. write "ATS0=0E0\13"
  61. matchread 30
  62. jump 59
  63. !
  64. !  Now that the modem hardware & flow control parameters are set, make sure any 
  65. !  protocol negotiation is disabled, and issue any modem specific features 
  66. !  here.  Make sure that MNP4/V.42, and MNP5-10/V.42bis negotiations are 
  67. !  disabled.  By the way, some V.32/V.32bis modems have an option to disable 
  68. !  Trellis error control,  which is part of the physical layer modulation.  
  69. !  This is not the same as MNP/V.42, and you do not want to disable it!
  70. !
  71. !  Make sure that the modem is configured so it does NOT require error control 
  72. !  to complete a link.  ARA 1.0 does all error correction/data compression in 
  73. !  software.  All ARA wants is the fastest raw data pipe it can get.  If the 
  74. !  script spends time trying to negotiate some error control, the modems and/or 
  75. !  Remote Access may time out.
  76. !
  77. !  It is important that the modem is configured so that it returns
  78. !  the connected speed, NOT the DTE speed.  The script need to know what the 
  79. !  real line speed is in order to set ARA's internal timers.  Some
  80. !  modems don't have the option to display the line speed.  In that case the 
  81. !  performance of the connection may not be optimal.
  82. !
  83. ! Next, disable MNP and error control, set the delay before disconnect,
  84. ! and extended result codes (CTS/RTS flow control and internal DTE<->DCE
  85. ! buffering was set when &F9 was issued , so it is not necessary to do it 
  86. ! again).
  87. !
  88. ! \N0 - "Normal" mode for communications (no LAPM or MNP)
  89. ! &D3 - DTR on/off resets modem 
  90. !
  91. @LABEL 5
  92. pause 5
  93. matchstr 1 6 "OK\13\10"
  94. write "AT\\N0&D3\13"
  95. matchread 30
  96. jump 59
  97. !
  98. !  The modem should now be properly configured.  Now check to see if the user 
  99. !  has turned off the modem speaker.  If they have, send an additional command 
  100. !  to turn it off.
  101. !
  102. ! If speaker on flag is true, jump to label 8.  Otherwise turn off the speaker.
  103. !
  104. @LABEL 6
  105. ifstr 2 8 "1"
  106. pause 5
  107. matchstr 1 8 "OK\13\10"
  108. write "ATM0\13"
  109. matchread 30
  110. jump 59
  111. !
  112. ! The modem is ready so enable answering, or originate a call.
  113. !
  114. @LABEL 8
  115. pause 5
  116. ifANSWER 30
  117. note "Dialing ^1" 3
  118. write "ATDT^1\13"
  119. !
  120. !  Be aware that different modems will have different format strings 
  121. !  to return connection results.  You need to understand the different possible 
  122. !  strings and set this area (and then answer area at label 31) to the 
  123. !  appropriate value.  Also, remember that the modem was configured to return 
  124. !  the connect speed if possible.
  125. !
  126. !  It's also useful if the modem can return busy, no dialtone, etc. since the script will 
  127. !  be able to exit quicker and let the user know what is going on.
  128. !
  129. !  Also note that the script waits at the bottom of label 9 for a 70 seconds, 
  130. !  rather then looping around.  Why?  Well, if the script re-issues the dial 
  131. !  command too soon, that would cause the modem to hang up.  At this point the 
  132. !  script should wait a reasonable amount of time for one of these strings to 
  133. !  return from the modem and take the appropriate action.
  134. !
  135. @LABEL 9
  136. matchstr 1  11 "CONNECT 1200\13\10"
  137. matchstr 2  12 "CONNECT 2400\13\10"
  138. matchstr 3  13 "CONNECT 4800\13\10"
  139. matchstr 4  19 "CONNECT 7200\13\10"
  140. matchstr 5  14 "CONNECT 9600\13\10"
  141. matchstr 6  20 "CONNECT 12000\13\10"
  142. matchstr 7  18 "CONNECT 14400\13\10"
  143. matchstr 8  50 "NO CARRIER\13\10"
  144. matchstr 9  50 "ERROR\13\10"
  145. matchstr 10 52 "NO DIALTONE\13\10"
  146. matchstr 11 53 "BUSY\13\10"
  147. matchstr 12 54 "NO ANSWER\13\10"
  148. matchread 700
  149. jump 59
  150. !
  151. !  All that is done for different connect speeds is to issue a 
  152. !  "CommunicatingAt" command.  Remember, the interface speed is locked
  153. !  to 19,200 bps so the script doesn't want to reset the serial speed after it 
  154. !  connects.
  155. !
  156. !  CommunicatingAt tells ARA what the actual line speed is so that it
  157. !  can set it's timers appropriately.  I guess performance would be
  158. !  sub-optimal if this is not set...
  159. !
  160. @LABEL 11
  161. note "Communicating at 1200 bps." 2
  162. CommunicatingAt 1200
  163. jump 15
  164. !
  165. @LABEL 12
  166. note "Communicating at 2400 bps." 2
  167. CommunicatingAt 2400
  168. jump 15
  169. !
  170. @LABEL 13
  171. note "Communicating at 4800 bps." 2
  172. CommunicatingAt 4800
  173. jump 15
  174. !
  175. @LABEL 19
  176. note "Communicating at 7200 bps." 2
  177. CommunicatingAt 7200
  178. jump 15
  179. !
  180. @LABEL 14
  181. note "Communicating at 9600 bps." 2
  182. CommunicatingAt 9600
  183. jump 15
  184. !
  185. @LABEL 20
  186. note "Communicating at 12000 bps." 2
  187. CommunicatingAt 12000
  188. jump 15
  189. !
  190. @LABEL 18
  191. note "Communicating at 14400 bps." 2
  192. CommunicatingAt 14400
  193. jump 15
  194. !
  195. ! Set CTS handshaking ON in the serial port (that's the 1 in the HSReset
  196. ! command below )
  197. !
  198. !  The modems have connected, so enable hardware handshaking on the serial 
  199. !  port.  If the script is answering a telephone call, just exit right away and 
  200. !  starting communicating.  If the script is dialing out, give the other end 
  201. !  some time (3 seconds in this example) to get ready to talk to this modem.
  202. !  Exit 0 tells Remote Access that the script was successful in attempting a
  203. !  connection.
  204. !
  205. @LABEL 15
  206. HSReset 0 1 0 0 0 0 
  207. ifANSWER 16
  208. pause 30
  209. @LABEL 16
  210. exit 0
  211. !
  212. !  Notice that the @ANSWER label is actually a comment here, and that 
  213. !  @ORIGINATE and @ANSWER start at the same place.  What's the point of having 
  214. !  separate entry points if they are not used?  Well, in the case of modems, 
  215. !  when they dial out or wait for a call, the setup is usually the same.  One 
  216. !  reason for separate entry points is when the script is not directly talking 
  217. !  to a modem, but maybe to a PBX or terminal server.  It may be necessary to 
  218. !  have completely different configuration for answering and originating 
  219. !  connections.
  220. !
  221. ! @ANSWER
  222. ! Set up the modem to answer the telephone.
  223. !
  224. @LABEL 30
  225. write "ATS0=1\13"
  226. matchstr 1 31 "OK\13\10"
  227. matchread 30
  228. jump 59
  229. !
  230. !  What is userhook 1 doing in label 32?  Here's the idea:  Either this script 
  231. !  controls a server that is waiting to answer the telephone, or it's waiting 
  232. !  for a callback to a connection that was initiated.  AppleTalk Remote Access 
  233. !  does a "passive" listen on the serial port (via the Serial Port Arbitrator) 
  234. !  so that other communications applications can use the serial port when ARA 
  235. !  is not using it.  When a call comes in for a server or callback, there
  236. !  will be about 5-14 seconds while the modems negotiate the connection.
  237. !  What would happen if a communications application on this Macintosh 
  238. !  wanted to use the serial port during that time?  Both connections
  239. !  would fail.  The userhook 1 command tells ARA to mark the serial port in 
  240. !  use.  When that happens, applications that want to use the serial port will 
  241. !  be told it's busy, and the incoming connection can complete.  With that in 
  242. !  mind, the strategy below is:  When the modem receives a ring, jump to label 
  243. !  32, issue the userhook 1 command, then jump back up to label 31, wait for 
  244. !  the connect result code and continue processing the script.
  245. !
  246. @LABEL 31
  247. matchstr 1  32 "RING\13\10"
  248. matchstr 2  11 "CONNECT 1200\13\10"
  249. matchstr 3  12 "CONNECT 2400\13\10"
  250. matchstr 4  13 "CONNECT 4800\13\10"
  251. matchstr 5  19 "CONNECT 7200\13\10"
  252. matchstr 6  14 "CONNECT 9600\13\10"
  253. matchstr 7  20 "CONNECT 12000\13\10"
  254. matchstr 8  18 "CONNECT 14400\13\10"
  255. matchstr 9  50 "NO CARRIER\13\10"
  256. matchstr 10 50 "ERROR\13\10"
  257. matchstr 11 52 "NO DIALTONE\13\10"
  258. matchstr 12 53 "BUSY\13\10"
  259. matchstr 13 54 "NO ANSWER\13\10"
  260. matchread 700
  261. jump 31
  262. !
  263. @LABEL 32
  264. userhook 1
  265. note "Answering phone..." 2
  266. jump 31
  267. !
  268. !  These are some common error messages when the line is busy, no dialtone, 
  269. !  etc. They are documented in the Scripting Language Guide.  When the script 
  270. !  exits with a code other than zero, Remote Access knows that the connection 
  271. !  failed, and will inform the user with a dialog.
  272. !
  273. ! 50: error messages
  274. !
  275. @LABEL 50
  276. exit -6021
  277. !
  278. @LABEL 52
  279. exit -6020
  280. !
  281. @LABEL 53
  282. exit -6022
  283. !
  284. @LABEL 54
  285. exit -6023
  286. !
  287. @LABEL 59
  288. exit -6019
  289. !
  290. ! Hang up the modem
  291. !
  292. @HANGUP
  293. @LABEL 60
  294. settries 0
  295. @LABEL 61
  296. write "ATH\13"
  297. matchclr
  298. matchstr 1 63 "OK\13\10"
  299. matchstr 2 63 "NO CARRIER\13\10"
  300. matchstr 3 63 "ERROR\13\10"
  301. matchread 30
  302. inctries
  303. iftries 3 63
  304. ! no response, try escape sequence
  305. write "+++"
  306. matchclr
  307. matchstr 1 62 "OK\13\10"
  308. matchread 20
  309. !
  310. ! No response from modem, toggle DTR
  311. !
  312. DTRClear
  313. pause 5
  314. DTRSet
  315. jump 61
  316. !
  317. @LABEL 62
  318. pause 5
  319. write "ATH\13"
  320. matchstr 1 63 "OK\13\10"
  321. matchstr 2 63 "NO CARRIER\13\10"
  322. matchstr 3 63 "ERROR\13\10"
  323. matchread 70
  324. jump 61
  325. !
  326. ! Recall factory settings
  327. !
  328. @LABEL 63
  329. pause 5
  330. matchclr
  331. matchstr 1 64 "OK\13\10"
  332. write "AT&F\13"
  333. matchread 30
  334. !
  335. ! Turn off auto answer
  336. !
  337. @LABEL 64
  338. write "ATS0=0\13"
  339. matchstr 1 65 "OK\13\10"
  340. matchread 30
  341. !
  342. ! Add delay to make sure other side of connection hangs up for call back.
  343. !
  344. @LABEL 65
  345. exit 0
  346.